import { SALE_ORDER_TYPE } from '@/model/type'
export const columns = ctx => {
  return [
    {
      prop: 'orderNo',
      label: '销售单号',
      headCheck: '1',
      minWidth: 120
    },
    {
      prop: 'saleOrderNo',
      label: ' 销售单名称',
      headCheck: '1',
      minWidth: 150,
      render: (h, row) => {
        return [
          <el-button
            type="text"
            onClick={() => {
              ctx.onExtendShow(row.id, 'sale')
            }}
          >
            {row.orderName}
          </el-button>
        ]
      }
    },
    {
      prop: 'customerName',
      label: '产品名称',
      headCheck: '1',
      minWidth: 150,
      render: (h, row) => {
        return [
          <el-button
            type="text"
            onClick={() => {
              ctx.onExtendShow(row.productId, 'product')
            }}
          >
            {row.productName}
          </el-button>
        ]
      }
    },
    {
      prop: 'productCode',
      headCheck: '1',
      label: '产品编号'
    },
    {
      prop: 'productType',
      headCheck: '1',
      label: '产品类型'
    },
    {
      prop: 'businessType',
      headCheck: '1',
      label: '业务类型'
    },
    {
      headCheck: '1',
      label: '销售单类型',
      render: (h, row) => {
        return [
          <el-tag size="medium" type={SALE_ORDER_TYPE[row.orderType] || 'primary'}>
            {row.orderType || '-'}
          </el-tag>
        ]
      }
    },
    {
      prop: 'saleTypeName',
      headCheck: '1',
      label: '销售方式'
    },
    {
      prop: 'parValue',
      headCheck: '1',
      label: '产品面值'
    },
    {
      prop: 'number',
      headCheck: '1',
      label: '数量'
    },
    {
      prop: 'operatorAccountName',
      headCheck: '1',
      label: '所属业务员'
    },
    {
      prop: 'signDate',
      headCheck: '1',
      label: '签单日期'
    },
    {
      prop: 'remark',
      headCheck: '1',
      label: '备注说明'
    },
    {
      prop: 'activeTime',
      headCheck: ctx.searchForm.tabType === '2' ? '1' : '0',
      label: '激活时间',
      hide: ctx.searchForm.tabType !== '2'
    },
    {
      button: true,
      label: '操作',
      fixed: 'right',
      headFixed: '1',
      width: 80,
      render: (h, row) => {
        const detail = (
          <el-button
            type="text"
            onClick={() => {
              ctx.onActive(row, 'detail')
            }}
          >
            详情
          </el-button>
        )

        const active = (
          <el-button
            type="text"
            onClick={() => {
              ctx.onActive(row, 'active')
            }}
          >
            激活
          </el-button>
        )
        // tab类型 1待激活，2已激活
        return ctx.searchForm.tabType === '1' ? [active] : [detail]
      }
    }
  ]
}

// 激活状态
export const activeStatus = [
  {
    label: '待激活',
    value: '1'
  },
  {
    label: '已激活',
    value: '2'
  },
  {
    label: '已关闭',
    value: '3'
  }
]

export const validityTime = [
  {
    value: '1',
    name: '固定有效期'
  },
  {
    value: '2',
    name: '按绑定后生效'
  },
  {
    value: '3',
    name: '按销售后生效'
  }
]

export const floatUnitOptions = [
  {
    value: 'day',
    name: '天'
  },
  {
    value: 'week',
    name: '周'
  },
  {
    value: 'month',
    name: '月'
  }
]
